<?php

m2import("model/entity/WineryOrderFormEntryEntity.php");
m2import("model/entity/WineryOrderFormCatEntity.php");

/*
    Action configuration:
        <conf:action mapping="productlist" class="WineryOrderFormCatAction" methodmapping="true" bypassViewMapping="true">
        </conf:action>
*/
class FrontendCategoriesAction extends phpinchains_WebAction {

    function index (env $env, phpinchains_ViewMapping $mapping, phpinchains_ActionForm $actionform) {
        $categories = new WineryOrderFormCatEntity($actionform);
        $actionform['categories'] = $categories->findAll(array('orderby' => 'wofcpos'));
        if (!$actionform['wof_cat_id'] && $GLOBALS['XICSAppParams']['dontselect'] != 'true') {
        	$cats = $actionform['categories'];
        	$actionform['wof_cat_id'] = $cats[0]['id'];
        	$GLOBALS['wof_cat_id'] = $cats[0]['id'];
        }
        if ($GLOBALS['XICSAppParams']['link_id']) {
        	$actionform['link_id'] = $GLOBALS['XICSAppParams']['link_id'];
        }
    }

}


?>